<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="html"
		doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
		doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" indent="no"/>

	<xsl:variable name="title">Wixi Edit: <xsl:value-of select="/topic/@id"/></xsl:variable>
	<xsl:variable name="topic"><xsl:value-of select="/topic/@id"/></xsl:variable>

	<xsl:template match="/">
		<html>
			<head>
				<title><xsl:value-of select="$title"/></title>
				<link rel="stylesheet" type="text/css" href="../style/wixi.css"/>
				<link rel="SHORTCUT ICON" href="../style/shortcut_icon.gif"/>
				<script type="text/javascript" src="../fckeditor/fckeditor.js"></script>
				<meta name="generator" content="Wixi"/>
				<meta http-equiv="Cache-Control" content="no-cache"/>
			</head>
			<body>
				<div class="DIV_PAGE_HDR">
					<h1><xsl:value-of select="$title"/></h1>
					<div class="DIV_SMALLTEXT">
						<a href="../view/?topic={$topic}"  >View</a> |
						<a href="../print/?topic={$topic}" >Printable</a> |
						<a href="../edit/?edit={$topic}"   >Edit</a> |
						<a href="../edit/?copy={$topic}"   >Copy</a> |
						<a href="../rawedit/?edit={$topic}">Raw Edit</a> |
						<a href="../rawedit/?copy={$topic}">Raw Copy</a> |
						<a href="../output/?topic={$topic}">Output XML</a>
					</div>
				</div>
				<xsl:apply-templates select="*" />
			</body>
		</html>
	</xsl:template>

	<xsl:template match="topic">
		<form method="POST">
			<div class="DIV_SECTION">
				<xsl:if test="@create='true'">
					<b>Creating New Topic</b> . . . 
					New Topic Name: <input name="new_topic" size="80" value="{@topic}" />
				</xsl:if>
				<xsl:if test="@create='false'"><b>Updating Existing Topic</b></xsl:if>
			</div>
			<xsl:apply-templates select="section" />
			<div class="DIV_SECTION">
				<p><input type="submit" name="save" value="Save" /></p>
			</div>
		</form>
	</xsl:template>

	<xsl:template match="section[@editable='true']">
		<div class="DIV_SECTION">
			<script type="text/javascript">
				var oFCKeditor = new FCKeditor( 'FCKeditor1' ) ;
				oFCKeditor.Height	= 300 ;
				oFCKeditor.BasePath = "../fckeditor/";
				oFCKeditor.Value	= 'This is some sample text...' ;
				oFCKeditor.Create() ;
			</script>
		</div>
	</xsl:template>

	<xsl:template match="section[@editable='false']">
		<div class="DIV_SECTION">
			<xsl:apply-templates select="p|h1|h2|h3|ol|ul|table"/>
		</div>
	</xsl:template>

	<xsl:template match="*[@type='string']">
		<input name="{position()}" value="{.}"/>
	</xsl:template>

	<xsl:template match="h1|h2|h3|li">
		<xsl:copy>
			<xsl:apply-templates select="node()"/>
		</xsl:copy>
	</xsl:template>

	<xsl:template match="ol|ul">
		<xsl:copy>
			<xsl:apply-templates select="ol|ul|li"/>
		</xsl:copy>
	</xsl:template>

	<xsl:template match="table">
		<xsl:copy>
			<xsl:apply-templates select="tr"/>
		</xsl:copy>
	</xsl:template>

	<xsl:template match="tr">
		<xsl:copy>
			<xsl:apply-templates select="td"/>
		</xsl:copy>
	</xsl:template>

	<xsl:template match="p|li|td|b|u|i">
		<xsl:copy><xsl:apply-templates select="node()"/></xsl:copy><xsl:text>  </xsl:text>
	</xsl:template>

</xsl:transform>
